package com.test;

import java.io.IOException;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/****
 * http://localhost:8080/servlet-demo/servletContextDemo1
 *  重定向到一个请求  需要得到context的跟目录
 *
 */
@WebServlet(value="/servletContextDemo1")
public class ServletContextDemo1  extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		ServletContext servletContext = req.getServletContext();
		resp.sendRedirect(servletContext.getContextPath()+"/hello");   //重定向
	}
}
